<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    Function.prototype.before = function(beforeFn){
        var self = this;
        return function(){
            beforeFn.apply(this,arguments);
            return self.apply(this.arguments);

        }

    }
    Function.prototype.after  =function(afterFn){
        var self = this;
        return function(){
           var ret = self.apply(this.arguments);
            afterFn.apply(this,arguments);
            return  ret;

        }
    }

    var fn1 = function(age){
        console.log("我的岁数是：" + age);
    }
   
   debugger;
    var fnResult = fn1.before(function(){
        console.log("before1");
    }).after(function(){
        console.log("after");
    });
    debugger;
    fnResult("张爱平");
</script>